SET(MODULE_NAME tsin-main)

INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/thirdparty/getoptpp/include"
                    "${PROJECT_SOURCE_DIR}/thirdparty/SDL/include"
                   )
LINK_DIRECTORIES("${PROJECT_SOURCE_DIR}/thirdparty/SDL/lib"
                )

SET(HEADERS ${PROJECT_SOURCE_DIR}/include/tsin/common.hpp
            ${PROJECT_SOURCE_DIR}/include/tsin/Main.hpp
            ${PROJECT_SOURCE_DIR}/include/tsin/Argument.hpp
            ${PROJECT_SOURCE_DIR}/include/tsin/SimpleMain.hpp
            ${PROJECT_SOURCE_DIR}/include/tsin/SimpleArgument.hpp
            ${PROJECT_SOURCE_DIR}/thirdparty/getoptpp/include/getoptpp/getopt_pp.h
            ${PROJECT_SOURCE_DIR}/thirdparty/getoptpp/include/getoptpp/getopt_pp_standalone.h
   )
SET(FILES main.cpp
          SimpleMain.cpp
          SimpleArgument.cpp
          ${PROJECT_SOURCE_DIR}/thirdparty/getoptpp/src/getopt_pp.cpp
   )

IF(WIN32)
SET(RC_FILES res.rc)
ENDIF()

IF(TSIN_ENABLE_MEM_CHECK)
SET(FILES ${FILES}
           ${PROJECT_SOURCE_DIR}/src/tsin/MemCheckStub.cpp)
ADD_DEFINITIONS(-DTSIN_MEMCHECK)
ENDIF()

SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR})

ADD_EXECUTABLE(${MODULE_NAME} ${EXECUTABLE_ATTR} ${FILES} ${HEADERS} ${RC_FILES})
SET_TARGET_PROPERTIES(${MODULE_NAME} PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(${MODULE_NAME} PROPERTIES OUTPUT_NAME "tsin")
TARGET_LINK_LIBRARIES(${MODULE_NAME} SDL tsin-config tsin-display tsin-input tsin-runtime tsin-selector tsin-util)
ADD_DEPENDENCIES(${MODULE_NAME} tsin-config tsin-display tsin-input tsin-runtime tsin-selector tsin-util)
INSTALL(TARGETS tsin-main DESTINATION .)
